home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Networking & Communications / Serial NB Sample Driver / Test / ARTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  2.6 KB  |  94 lines  |  [TEXT/MPS ]

  1. /********************************************************************************/
  2. /*                                                                                */
  3. /*        ARTest.c - A/ROSE driver test tool.                                        */
  4. /*                                                                                */
  5. /*        Richard W. Mincher.        February 20, 1990.                                */
  6. /*                                                                                */
  7. /*        Copyright © 1990, Apple Computer, Inc.  All rights reserved.            */
  8. /*                                                                                */
  9. /********************************************************************************/
  10.  
  11.  
  12. #include    "types.h"
  13. #include    "stdio.h"
  14. #include    "OSUtils.h"
  15.  
  16. #include    "Desk.h"
  17. #include    "files.h"
  18. #include    "memory.h"
  19. #include    "CursorCtl.h"
  20.  
  21. #include    "ARDriver.h"
  22.  
  23. short    ref;
  24.  
  25. main()
  26. {
  27.     short            err;
  28.     long            i, j, k;
  29.     ParamBlockRec    pbrec;
  30.     ParamBlockRec    pbrec1;
  31.     char            temp[101];
  32.     
  33.     InitCursorCtl(0);
  34.     for(i=0; i < sizeof(ParamBlockRec); i++)
  35.     {
  36.         ((char *)(&pbrec))[i] = 0;
  37.         ((char *)(&pbrec1))[i] = 0;
  38.     }
  39.     fprintf( stderr, "Opendriver called.\n");
  40.     err = AROpenDriver( "\pSerial NB:snbaB3", &ref );
  41.     fprintf( stderr, "Opendriver returned.  ioResult = %d\n", err);
  42.     pbrec.cntrlParam.csCode = 10;
  43.     pbrec.cntrlParam.csParam[0] = 0x101;
  44.     pbrec.cntrlParam.csParam[1] = 0x1113;
  45.     pbrec.cntrlParam.csParam[2] = 0x0;
  46.     pbrec.cntrlParam.csParam[3] = 0x101;
  47.     err = ARPBControl (&pbrec, 0 );
  48.     fprintf( stderr, "Control returned.  ioResult = %d\n", err);
  49.     err = ARPBStatus (&pbrec, 0 );
  50.     fprintf( stderr, "Status returned.  ioResult = %d\n", err);
  51.     for(i=0; i < 100; i++)
  52.     {
  53.         pbrec.ioParam.ioBuffer = "Hello\nHello\nHello\nHello\nHello\nHello\n";
  54.         pbrec.ioParam.ioReqCount = 36;
  55.         err = ARPBWrite (&pbrec, 1 );
  56.         fprintf( stderr, "Write returned.  ioResult = %d\n", err);
  57.         pbrec1.ioParam.ioBuffer = "World\nWorld\nWorld\nWorld\nWorld\nWorld\n";
  58.         pbrec1.ioParam.ioReqCount = 36;
  59.         err = ARPBWrite (&pbrec1, 1 );
  60.         fprintf( stderr, "Write returned.  ioResult = %d\n", err);
  61.         while ((pbrec.ioParam.ioResult > 0) || (pbrec1.ioParam.ioResult > 0))
  62.         {
  63.             SpinCursor(1);
  64.             PushAIPC();
  65.         }
  66.     }
  67.     for(i=0; i < 5; i++)
  68.     {
  69.         for(j=0; j < 5; j++)
  70.         {
  71.             Delay( 60 * 4, &k );
  72.             pbrec.cntrlParam.csCode = 2;
  73.             err = ARPBStatus (&pbrec, 0 );
  74.             fprintf( stderr, "Status returned.  ioResult = %d  length = %d\n",
  75.                 err, pbrec.cntrlParam.csParam[1] );
  76.         }
  77.         pbrec.ioParam.ioBuffer = temp;
  78.         pbrec.ioParam.ioReqCount = 100;
  79.         err = ARPBRead (&pbrec, 1 );
  80.         while (pbrec.ioParam.ioResult > 0)
  81.         {
  82.             SpinCursor(1);
  83.             PushAIPC();
  84.         }
  85.         temp[pbrec.ioParam.ioActCount] = 0;
  86.         fprintf( stderr, "Read returned.  ioResult = %d\n", err);
  87.         fprintf( stderr, "Read length = %d data = \"%s\"\n",
  88.             pbrec.ioParam.ioActCount, temp );
  89.     }
  90.     err = ARCloseDriver( ref );
  91.     fprintf( stderr, "Close returned.  ioResult = %d\n", err);
  92.     exit(0);
  93. }
  94.